/**
 * Created by liguangsong on 16/8/15.
 */
$(document).ready(function() {

    modifyShopCarNumber();

    $("#go").click(function() {
        window.location.href = "./goodsList.html";
    });

    $("#to_main").click(function() {
        window.location.href = "./main.html";
    });

    $("#to_goodsList").click(function() {
        window.location.href = "./goodsList.html";
    });

    $("#to_shop_car").click(function() {
        window.location.href = "./shoppingCart.html";
    })
});


function modifyShopCarNumber() {
    //window.localStorage.clear();
    if (window.localStorage.shoppingCart != null) {
        var shoppingCart = JSON.parse(window.localStorage.shoppingCart);
        var count = 0;
        _.times(shoppingCart.length, function(i) {
            count += parseInt(shoppingCart[i]["count"]);
        });

        $(".nav_shop_car p span").text(" (" +  count + ")");
    }
}

function getLocalData() {
    var shoppingCartInfo = window.localStorage.shoppingCart == undefined ? [] : JSON.parse(window.localStorage.shoppingCart);
    return shoppingCartInfo;
}